package cn.kmsoft.common;

import java.io.Serializable;
import java.util.UUID;

/**
 * @author : cqwensten
 * @description : todo
 * @email : cqwensten@163.com
 * @date : 2023/2/22
 */
public class DebugMsgInfo implements Serializable, Comparable{
    private String id;
    private int order;
    private String msgInfo;

    public DebugMsgInfo(){
        //
    }
    public DebugMsgInfo(int order,String msgInfo){
        this.id= UUID.randomUUID().toString();
        this.order= order;
        this.msgInfo= msgInfo;
    }

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public int getOrder() {
        return order;
    }
    public void setOrder(int order) {
        this.order = order;
    }

    public String getMsgInfo() {
        return msgInfo;
    }
    public void setMsgInfo(String msgInfo) {
        this.msgInfo = msgInfo;
    }

    @Override
    public String toString() {
        return "DebugMsgInfo{" +
                "id='" + id + '\'' +
                ", order=" + order +
                ", msgInfo='" + msgInfo + '\'' +
                '}';
    }

    /**
     * order排序：以数据优先级order和id代码，进行排序
     */
    @Override
    public int compareTo(Object o) {
        DebugMsgInfo debugMsgInfo = (DebugMsgInfo) o;
        int ord = this.order - debugMsgInfo.getOrder();
        if (ord == 0) {
            return compare(this.id, debugMsgInfo.getId());
        }
        return ord;
    }

    public int compare(String o1, String o2) {
        return o2.compareTo(o1);
    }
}
